home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / Graphic Elements 2 / Extras / Paths.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-20  |  2.4 KB  |  105 lines  |  [TEXT/MPS ]

  1. /*
  2.     Paths.h
  3.     
  4.     Paths routines for Graphic Elements
  5.     
  6.     Copyright 1993 by Al Evans
  7.     
  8.     11/10/93
  9.     
  10. */
  11.  
  12. #ifdef applec
  13. #ifndef __cplusplus
  14. #ifndef PRELOAD
  15. #pragma load "::ToolKit.precompile"
  16. #define PRELOAD
  17. #endif
  18. #endif
  19. #endif
  20.  
  21. /*
  22.     A simple path system for programmed animation. A PathRec contains a
  23.     pointer to a sequence of PathEntries and fields to hold the results
  24.     of processing those PathEntries.
  25.     
  26.     The FrameSeqGraphic which uses paths calls InitPath to initialize
  27.     the PathRec, then calls GetNextStep during its AutoChangeProc update
  28.     its PathRec. On return from GetNextStep, it changes frames if 
  29.     PathRec.currFrame is non-zero and moves if PathRec.currXMove or
  30.     PathRec.currYMove is non-zero.
  31.     
  32.     Each PathEntry is one step in the path. Each PathEntry has a command,
  33.     a parameter, and x value, and a y value. Their effects on the fields
  34.     of the PathRec depend on the command:
  35.         
  36.         absMotionCmd: 
  37.                 PathRec.currFrame = param;
  38.                 PathRec.currXMove = xVal;
  39.                 PathRec.currYMove = yVal;
  40.         
  41.         relMotionCmd:
  42.                 PathRec.currFrame = param;
  43.                 PathRec.currXMove += xVal;
  44.                 PathRec.currYMove += yVal;
  45.                 
  46.     Paths can also contain control commands:
  47.     
  48.         gotoCmd:
  49.                 Reset the current step in the path to (param) and
  50.                 process the PathEntry found there.
  51.         resetCmd:
  52.                 Reset the current step in the path to zero. Must
  53.                 be included as the last step in each path.
  54.         repeatCmd:
  55.                 Only meaningful before a relMotionCmd. Causes the
  56.                 next command to be repeated (param) times. If this
  57.                 command includes a frame change, the frame is changed
  58.                 only on the first execution.
  59. */
  60.  
  61. typedef struct {
  62.     signed char        command;
  63.     unsigned char    param;
  64.     signed char        xVal;
  65.     signed char        yVal;
  66. }    PathEntry, *PathEntryPtr;
  67.  
  68. typedef struct {
  69.     short            currStep;
  70.     short            currFrame;
  71.     short            currXMove;
  72.     short            currYMove;
  73.     short            count;
  74.     short            sp;
  75.     short            stack[16];
  76.     PathEntryPtr    path;
  77. } PathRec, *PathRecPtr;
  78.  
  79. typedef enum {
  80.         absMotionCmd    =     (signed char) 0x20,
  81.         relMotionCmd    =    (signed char) 0x21,
  82.         //commands < 0 manipulate path pointer
  83.         repeatCmd        =    (signed char) 0xD1,
  84.         goToCmd            =    (signed char) 0xE0,
  85.         goSubCmd        =    (signed char) 0xE1,
  86.         returnCmd        =    (signed char) 0xE2,
  87.         resetCmd        =    (signed char) 0xFF
  88. } PathCommand;
  89.     
  90. #ifdef __cplusplus
  91. extern "C" {
  92. #endif
  93.  
  94. void InitPath(PathRecPtr path);
  95.  
  96. void GetNextStep(PathRecPtr path);
  97.  
  98. void DoPathGoTo(PathRecPtr path, short gotoStep);
  99.  
  100. void DoPathGoSub(PathRecPtr path, short subRtnStep);
  101.  
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105.